package dao

import (
	"fmt"

	"gitee.com/liu_deping/gin-vue/db"
	"gitee.com/liu_deping/gin-vue/model"
)

func GetUserByPhone(phone string) (*model.User, error) {
	user := &model.User{}
	//1.数据库查询第一条符合的数据
	err := db.DB.Debug().Where("phone=?", phone).First(user).Error
	if err != nil {
		return nil, err
	}
	fmt.Println("db=", user)
	return user, nil
}

func IsPhoneExist(phone string) bool {
	var user model.User
	db.DB.Where("phone=?", phone).First(&user)
	if user.ID != 0 {
		return true
	}
	return false
}
